﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace AdminSystem.Repositories.Interfaces
{
    /// <summary>
    /// 仓储接口
    /// </summary>
    /// <typeparam name="T">实体</typeparam>
    public interface IBaseRepositories<T> where T : class
    {
        Task<IList<T>> GetAll();
        Task<List<T>> GetAll(Expression<Func<T, bool>> expression);
        Task<List<T>> QueryAsync<TKey>(Expression<Func<T, bool>> expression,Expression<Func<T,TKey>> orderby);
        Task<bool> ExistsAsync(Expression<Func<T, bool>> expression);
        Task<T> GetById(int id);

        Task<T> Add(T entity);    
        Task<int> Update(T entity);
        Task<int> Delete(int id);
        Task<int> AddRange(IEnumerable<T> entities);
        Task<int> UpdateRange(IEnumerable<T> entities);
        Task<int> DeleteRange(IEnumerable<int> ids);
        /// <summary>
        /// 根据条件表达式获取单个实体
        /// </summary>
        /// <param name="condition"></param>
        /// <returns></returns>
        Task<T> GetByConditionAsync(Expression<Func<T, bool>> condition);
        /// <summary>
        /// 单个删除
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<int> DeleteAsync(T entity);
        
       
    }
}
